home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-04-13 | 2.1 KB | 104 lines | [TEXT/ttxt] |
- -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C)
- -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
- --
- expanded class BOOLEAN
- --
- -- Note : corresponding C type is "int"
- --
- inherit
- BOOLEAN_REF
- redefine
- infix "and", infix "and then", infix "or",
- infix "or else", infix "implies", infix "xor",
- prefix "not", to_string, to_integer, out_in_tagged_out_memory,
- fill_tagged_out_memory
- end;
-
- feature
-
- infix "and" (other: BOOLEAN): BOOLEAN is
- -- `and' of Current with `other'.
- --
- -- Note: when evaluation of `other' has no side effects, it
- -- may be better to use "and then" to avoid execution-time
- -- overhead.
- do
- Result := Current and then other;
- end;
-
- infix "and then" (other: BOOLEAN): BOOLEAN is
- -- Semi-strict `and' of Current with `other'.
- external "CSE"
- end;
-
- infix "implies"(other: BOOLEAN): BOOLEAN is
- -- Does Current imply `other'.
- external "CSE"
- end;
-
- infix "or" (other: BOOLEAN): BOOLEAN is
- -- `or' of Current with `other'
- --
- -- Note: when evaluation of `other' has no side effects, it
- -- may be better to use "or else" to avoid execution-time
- -- overhead.
- do
- Result := Current or else other;
- end;
-
- infix "or else" (other: BOOLEAN): BOOLEAN is
- -- Semi-strict `or' of Current with `other'
- external "CSE"
- end;
-
- infix "xor" (other: BOOLEAN): BOOLEAN is
- -- `xor' of Current with `other'
- do
- if Current then
- Result := not other;
- else
- Result := other;
- end;
- end;
-
- prefix "not": BOOLEAN is
- -- `not' of Current.
- do
- if Current then
- else
- Result := true;
- end;
- end;
-
- to_string: STRING is
- do
- if Current then
- Result := "true";
- else
- Result := "false";
- end;
- end;
-
- to_integer: INTEGER is
- do
- if Current then
- Result := 1;
- else
- Result := 0;
- end;
- end;
-
- append_in(str: STRING) is
- do
- str.append(to_string);
- end;
-
- feature -- Object Printing :
-
- out_in_tagged_out_memory, fill_tagged_out_memory is
- do
- tagged_out_memory.append(to_string);
- end;
-
- end -- BOOLEAN
-